#include "Common.hpp"

int main()
{

    key_t key = GetKey();
    int shmid = CreatShmHelper(key, IPC_CREAT | 0644);
    char *s = static_cast<char *>(shmat(shmid, nullptr, 0));
    std::cout << "attach shm done\n";
    int fd = open(filename.c_str(), O_WRONLY);

    for (int c = 0; c < 26; c++)
    {
        // s[c] = c + 'a';
        // std::cout << "write:" << (char)c + 'a' << "done\n";
        strcpy(s,"I am Process A\n");
        sleep(1);
        int code = 1;
        write(fd, (char *)&code, sizeof(code));
    }
    // sleep(5);

    std::cout << "dettach shm done\n";

    shmdt(s);
    close(fd);
    return 0;
}